package game;
import java.awt.*;

public class Fruit {
    private String symbol;
    private int x;
    private int y;
    private double vx;
    private double vy;
    private static final double GRAVITY = 0.1;
    private boolean isBomb; // 标记是否为炸弹
    private boolean isSpecial; // 标记是否为特殊水果
    private int specialEffect; // 特殊效果类型
    private double rotationAngle; // 旋转角度

    public Fruit(String symbol, int x, int y, double vx, double vy, boolean isBomb, boolean isSpecial, int specialEffect) {
        this.symbol = symbol;
        this.x = x;
        this.y = y;
        this.vx = vx;
        this.vy = vy;
        this.isBomb = isBomb;
        this.isSpecial = isSpecial;
        this.specialEffect = specialEffect;
        this.rotationAngle = 0;
    }

    public String getSymbol() {
        return symbol;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public boolean isBomb() {
        return isBomb;
    }

    public boolean isSpecial() {
        return isSpecial;
    }

    public int getSpecialEffect() {
        return specialEffect;
    }

    public void move() {
        vy += GRAVITY;
        x += vx;
        y += vy;
        rotationAngle += 0.05; // 每次移动旋转一定角度
    }

    public boolean isOutOfBounds(int height) {
        return y > height;
    }

    public boolean isCut(int mouseX, int mouseY) {
        int size = 30;
        return mouseX >= x - size / 2 && mouseX <= x + size / 2 &&
                mouseY >= y - size / 2 && mouseY <= y + size / 2;
    }

    public void draw(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setFont(new Font("Segoe UI Emoji", Font.PLAIN, 30));
        g2d.rotate(rotationAngle, x, y);
        g2d.drawString(symbol, x, y);
        g2d.rotate(-rotationAngle, x, y); // 恢复旋转状态
    }
}